﻿// HSS.Forms.LogTextBox.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       LogTextBox.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.Forms
{
	#region Using Directives
	using System.IO;
	using System.Text;
	using System.Windows.Forms;
	#endregion

	#region LogTextBox
	/// <summary>
	/// LogTextBox is custom Textbox that has a TextBoxWriter
	/// that can be assigned to the Console.Out or any other
	/// write systems.
	/// </summary>
	public class LogTextBox : TextBox
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public LogTextBox()
		{
			this.Writer = new TextBoxWriter(this);
			this.InitializeComponent();
		}
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="textBoxWriter">A <see cref="TextBoxWriter"/> for this LogTextBox</param>
		public LogTextBox(TextBoxWriter textBoxWriter)
		{
			this.Writer = textBoxWriter;
			this.InitializeComponent();
		}
		#endregion

		#region Properties
		/// <summary>
		/// Gets the TextBoxWriter instance that can be set
		/// to the Console.Out to pick Console.Write calls.
		/// </summary>
		public TextBoxWriter Writer
		{
			get;
			private set;
		}
		#endregion

		#region Methods
		private void InitializeComponent()
		{
			this.SuspendLayout();
			// 
			// LogTextBox
			// 
			this.BackColor = System.Drawing.Color.Black;
			this.Font = new System.Drawing.Font("Consolas", 11.25F);
			this.ForeColor = System.Drawing.Color.Lime;
			this.Multiline = true;
			this.ReadOnly = true;
			this.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.Size = new System.Drawing.Size(100, 20);
			this.ResumeLayout(false);

		}
		#endregion
	}
	#endregion
}